# Maintainer: Jürgen Hötzel <juergen@archlinux.org>

_pkgname=bos
pkgname=ocaml-${_pkgname}
pkgver=0.2.1
pkgrel=1
pkgdesc="OCaml support for basic and robust interaction with the operating system"
arch=('loong64' 'x86_64')
url="https://erratique.ch/software/bos"
license=('ISC')
depends=('ocaml' 'ocaml-fpath' 'ocaml-astring' 'ocaml-rresult' 'ocaml-fmt' 'ocaml-logs')
makedepends=('ocaml-findlib' 'ocamlbuild' 'ocaml-topkg' 'opam')
options=('!strip')
source=("https://erratique.ch/software/${_pkgname}/releases/${_pkgname}-${pkgver}.tbz")
sha256sums=('d8d62e786b10d697e0457205a8eedeaa27ebcc90f1855f18df190cac2e3d8f37')


build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  ocaml pkg/pkg.ml build --dev-pkg false
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  opam-installer --prefix="$pkgdir/usr" --libdir='lib/ocaml' --docdir='share/doc'

  mv "${pkgdir}/usr/share/doc/${_pkgname}" "${pkgdir}/usr/share/doc/${pkgname}"
  install -dm755 "$pkgdir/usr/share/licenses/$pkgname"
  ln -sf "/usr/share/doc/$pkgname/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"
}
